home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jaz_clib.arc / JZMIDSTR.C < prev    next >
Text File  |  1989-04-09  |  818b  |  31 lines

  1. /*
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │jzmidstr.c                                     │
  4. │Return the substring of a string.                         │
  5. │Specify the String, the starting position, and the number of chars to copy  │
  6. │                                         │
  7. │ (C) JazSoft Software by Jack A. Zucker (301) 794-5950              │
  8. └────────────────────────────────────────────────────────────────────────────┘
  9. */
  10. char *jzmidstr(fstr,ffrom,flen)
  11. char *fstr;
  12. int ffrom,flen;
  13. {
  14.   static char wstr[256];        /* static work buffer */
  15.   unsigned int wlen,newlen;
  16.  
  17.   if ((wlen = strlen(fstr)) < (ffrom+1))    /* don't go beyond string */
  18.     return(0);
  19.  
  20.   strncpy(wstr, fstr + ffrom, flen);    /* copy into work storage */
  21.  
  22.   newlen = flen - ffrom + 1;
  23.  
  24.   if (newlen >= flen)
  25.     wstr[newlen] = 0;
  26.  
  27.   return(wstr);
  28.  
  29. }
  30.  
  31.